/*
 *	There is another way to check for the bits (ie. not by iterating all n bits).
 *	Using 2 int instead: one for on bit & don't care, one for off bit & don't care.
 */

#include <iostream>
#include <cstdio>
#include <string>
#include <deque>
#include <sstream>

#define inf 1000000000

using namespace std;

struct path {
	long time;
	string present, fix;
};

int n, m, ncount;
long d[1<<20];
path p[100];
deque<long> q;

void init()
{
	q.resize(0);
	for (int i = 0; i < (1<<20); i++) d[i] = inf;
	int start = (1 << n) - 1;
	d[start] = 0;
	q.push_front(start);
}

int getBit(int b, long k)
{
	return (k >> b) & 1;
}

void toggleBit(int b, long* k)
{
	(*k) ^= (1 << b);
}

void BFS()
{
	while (!q.empty())
	{
		long u = q.front();
		q.pop_front();
		for (int i = 0; i < m; i++)
		{
			// check if present is correct
			bool ok = true;
			for (int j = 0; j < n; j++)
			{
				if (p[i].present[j] == '0') continue;
				if ((p[i].present[j] == '+' && getBit(j, u) == 0) ||
				    (p[i].present[j] == '-' && getBit(j, u) == 1))
				{
					ok = false;
					break;
				}
			}

			// Update with the fixed patch
			if (ok)
			{
				long v = u;
				for (int j = 0; j < n; j++)
				{
					if (p[i].fix[j] == '0') continue;
					if (p[i].fix[j] == '+' && getBit(j, v) == 0) toggleBit(j, &v);
					if (p[i].fix[j] == '-' && getBit(j, v) == 1) toggleBit(j, &v);
				}
				if (d[v] > d[u] + p[i].time)
				{
					d[v] = d[u]+p[i].time;
					q.push_front(v);
				}
			}
		}
	}
}

void resolve(int i)
{
	for (int l = 0, r = n-1; l < r; l++, r--)
	{
		char temp = p[i].present[l];
		p[i].present[l] = p[i].present[r];
		p[i].present[r] = temp;
	}
	for (int l = 0, r = n-1; l < r; l++, r--)
	{
		char temp = p[i].fix[l];
		p[i].fix[l] = p[i].fix[r];
		p[i].fix[r] = temp;
	}
}

int main()
{
	ncount = 0;
	while (scanf("%d %d\n", &n, &m))
	{
		if (n == 0 && m == 0) break;

		for (int i = 0; i < m; i++)
		{
			cin >> p[i].time;
			string s;
			getline(cin, s);
			istringstream ss(s);
			ss >> p[i].present >> p[i].fix;
			resolve(i);
		}

		init();
		BFS();

		ncount++;
		cout << "Product " << ncount << endl;
		if (d[0] == inf) cout << "Bugs cannot be fixed." << endl;
		else cout << "Fastest sequence takes " << d[0] << " seconds." << endl;
		cout << endl;

	};

	return 0;
}
